package io.renren.modules.learn.controller;

import io.renren.common.utils.R;
import io.renren.modules.learn.service.PythonChapterService;
import io.renren.modules.learn.service.PythonKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/learn/basic")
public class LearnBasicController {
    @Autowired
    private PythonChapterService chapterService;
    @Autowired
    private PythonKnowledgeService knowledgeService;

    @GetMapping("/chapters")
    public R getChapters() {
        return R.ok().put("data", chapterService.getAllChapters());
    }

    @GetMapping("/knowledge")
    public R getKnowledgeByChapter(@RequestParam Integer chapterId) {
        return R.ok().put("data", knowledgeService.getByChapterId(chapterId));
    }

    @GetMapping("/knowledge/{id}")
    public R getKnowledgeDetail(@PathVariable Integer id) {
        return R.ok().put("data", knowledgeService.getById(id));
    }
} 